package com.crm.service.saling.impl;

import com.crm.dao.saling.PlaningPayDao;
import com.crm.exception.ServiceException;
import com.crm.pojo.PlaningPay;
import com.crm.service.saling.PlaningPayService;
import com.crm.vo.PlaningPayClientContractUserInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by dr5hx on 2018/9/3
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class PlaningPayServiceImpl implements PlaningPayService {
    @Autowired
    private PlaningPayDao planingPayDao;

    @Override
    public PlaningPay save(PlaningPay planingPay) {
        return planingPayDao.save(planingPay);
    }

    @Override
    public List<PlaningPayClientContractUserInfoVO> getPlaningPayClientContractUserInfoVOList(int page, int rows) throws ServiceException {
        try {
            return planingPayDao.getPlaningPayClientContractUserInfoVOList(new PageRequest(page - 1, rows));
        } catch (Exception e) {
            e.printStackTrace();
            throw new ServiceException(e);
        }
    }

    @Override
    public PlaningPay findOne(Long planingPayId) {
        return planingPayDao.findOne(planingPayId);
    }

    @Override
    public Long getPlaningPayListCount() {
        return planingPayDao.getPlaningPayListCount();
    }

}
